#include <dirent.h>

int select(const struct dirent *dir)
{
	if(strlen(dir->d_name) == 4) {
		return 1;
	} else {
		return 0;
	}
}
main()
{
	struct dirent **namelist;
	int i,total;
	total = scandir("/",&namelist,select,0);
	if(total < 0) {
		perror("scandir error");
	} else {
		for(i = 0;i < total; i++)
		printf("%s\n",namelist[i]->d_name);
		printf("total = %d\n",total);
	}
}
